<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		ul {
			list-style-type: none;
		}
	</style>
	<script src="jquery-3.3.1.min.js"></script>
	<script>
		$(function(){
			$("#btn").click(function() {
				 $("#uu>li:odd").css("backgroundColor","yellow");
				 $("#uu>li:even").css("backgroundColor","red");
			});
		});
	</script>
</head>
<body>
	<input type="button" id="btn" value="隔行变色">
	<ul id="uu">
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
		<li>5</li>
		<li>6</li>
		<li>7</li>
		<li>8</li>
	</ul>
</body>
</html>